{extend name="layout" /}
{block name="button"}
{if authCheck('node/nodeadd')}
&nbsp;<button type="button" onclick="add()" class="btn btn-mystyle btn-sm">添加分类</button>
{/if}
{/block}
{block name="content"}
<div class="table-margin">
    <table class="table table-bordered table-header" id="list-table">
        <thead>
        <tr>
            <td>分类</td>
            <td>排序</td>
            <td>创建时间</td>
            <td>修改时间</td>
            <td>启用状态</td>
            <td class="w20">操作</td>
        </tr>
        </thead>
        <tbody>
        {foreach name="nodes" item="vo"}
            <tr>
                <td id="{$vo.id}"><span class="glyphicon glyphicon-chevron-right"></span>&nbsp;&nbsp;{$vo['name']}</td>
                <td><input type="text" onchange="updateSort('CategoryModel','id','{$vo.id}','number',this)" oninput="this.value=this.value.replace(/[^\d]/g,'')" size="4" value="{$vo.number}" class="form-control" style="width:80px" /></td>
                <td>{$n['create_time']}</td>
                <td>{$n['update_time']}</td>
                <td>
                    <div class="switch">
                        <input class="switch-checkbox" id="on_off_switch" type="checkbox">
                        <label class="switch-label" for="on_off_switch">
                            <span class="switch-inner" data-on="开启" data-off="关闭"></span>
                            <span class="switch-switch"></span>
                        </label>
                    </div>
                </td>
                <td>
                    {$vo['operate']}
                </td>
            </tr>
        {/foreach}
        </tbody>
    </table>
</div>
<div class="modal fade" id="bjy-edit" tabindex="-1" role="dialog" aria-labelledby="modaledit" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="modaledit"> 菜单设置</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="{:url('Category/edit')}" method="post">
                    <input type="hidden" name="id">
                    <table class="table table-bordered contact-template-form">
                        <tbody><tr>
                            <td width="20%" align="right">菜单名：</td>
                            <td>
                                <input class="form-control" type="text" name="node_name" required="" aria-required="true">
                            </td>
                        </tr>
                        <tr>
                            <td width="20%" align="right">路径：</td>
                            <td>
                                <input class="form-control" type="text" name="mca" required="" aria-required="true">
                                一级菜单：控制器 如：Nav
                                <br/>
                                二级菜单：控制器/方法 如：Nav/index
                            </td>
                        </tr>
                        <tr>
                            <th></th>
                            <td>
                                <input class="btn btn-primary" type="submit" value="提交">
                            </td>
                        </tr>
                        </tbody></table>
                </form>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    // 编辑菜单
    function edit(id,name,mca){
        $("#bjy-edit input[name='id']").val(id);
        $("#bjy-edit input[name='node_name']").val(name);
        $("#bjy-edit input[name='mca']").val(mca);
        $('#bjy-edit').modal('show');
    }
    function delNode(id){
        layer.confirm('确认删除此分类吗?', {icon: 3, title:'提示'}, function(index){
            $.getJSON("{:url('category/remove')}", {'id' : id}, function(res){
                showSuccess(res);
            });
            layer.close(index);
        });
    }
</script>
{/block}
